var express = require('express')
var router = express.Router()
const { loginService } = require('../service/adminService')
const {formatResponse} = require('../utils/tool.js')

/* GET home page. */
router.post('/login', async function (req, res, next) {
  console.log(req.body, "访问首页")
  // 首先是验证码的验证
  // 假设验证密码已经通过了,接下来账号密码的验证，应该去业务逻辑层

  const data = await loginService(req.body)
  if(data.token){
      res.setHeader('authorization',data.token)
  }
  res.send(formatResponse(200,data,'成功'))
})

module.exports = router
